/*
 * jTalkFrame.java
 *
 * Created on 6 novembre 2007, 20:08
 */

package jtalk.view;

import jtalk.controller.DefaultController;

/**
 *
 * @author  remy
 */
public class jTalkFrame extends javax.swing.JFrame {
            
    /**
	 * 
	 */
	private static final long serialVersionUID = 8937110405355106561L;
	/** Creates new form jTalkFrame */
    public jTalkFrame(DefaultController controller) {
        this.controller = controller;
        initComponents();        
        init();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jMenuBar = new javax.swing.JMenuBar();
        connectionMenu = new javax.swing.JMenu();
        disconnectMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("jTalk");
        setName("frame");
        connectionMenu.setText("Connection");
        disconnectMenuItem.setText("disconnect");
        disconnectMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disconnectMenuItemActionPerformed(evt);
            }
        });

        connectionMenu.add(disconnectMenuItem);

        exitMenuItem.setText("exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });

        connectionMenu.add(exitMenuItem);

        jMenuBar.add(connectionMenu);

        setJMenuBar(jMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 186, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 378, Short.MAX_VALUE)
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void disconnectMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disconnectMenuItemActionPerformed
        mainPanel.getController().disconnect();
    }//GEN-LAST:event_disconnectMenuItemActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed
        
    private void init() {         
        
        mainPanel = new MainPanel(this.controller);
        setContentPane(mainPanel);        
        
        controller.addView(mainPanel);
        
    }            
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu connectionMenu;
    private javax.swing.JMenuItem disconnectMenuItem;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenuBar jMenuBar;
    // End of variables declaration//GEN-END:variables
    
    //Other variables
    private DefaultController controller;    
    private MainPanel mainPanel;
    //End
    
}
